import os

ifile = 'albano.txt'
ofile = 'fm_albano.txt'

os.chdir(r'D:\research\packing\physical_packing\data\polygons')

ifh = open(ifile, 'r')
ofh = open(ofile, 'w')

aline = ifh.readline()

while (aline != ''):
    tokens = aline.split()
    idx = tokens[0]
    num = tokens[1]
    aline = ifh.readline()
    x = aline.split()
    x = x[1:]
    aline = ifh.readline()
    y = aline.split()
    y = y[1:]
    # output
    ofh.write('PIECE ' + idx +'\n')
    ofh.write('QUANTITY\n')
    ofh.write(num + '\n')
    ofh.write('NUMBER OF VERTICES\n')
    ofh.write(str(len(x)) + '\n')
    ofh.write('VERTICES (X,Y)\n')
    for i in range(0,len(x)):
        ofh.write(x[i] + ' ')
        ofh.write(y[i] + '\n')
    ofh.write('\n')
    aline = ifh.readline()

ifh.close()
ofh.close()
quit()
